<!-- 
  深层级过渡与显式过渡时长

  过渡模式
    mode 属性
      out-in      先出后进入
      in-out      先进再出

 -->

<template>
  <div>
    <h1>纯CSS动画效果</h1>

    <van-button @click="isShow = !isShow">Toggle</van-button>

    <Transition name="fade">
      <button v-if="state === 1" @click="state = 2">111</button>
      <button v-else-if="state === 2" @click="state = 3">222</button>
      <button v-else-if="state === 3" @click="state = 1">333</button>
    </Transition>

    <Transition name="slide-up" mode="out-in">
      <button v-if="docState === 'saved'" @click="docState = 'edited'">Edit</button>
      <button v-else-if="docState === 'edited'" @click="docState = 'editing'">Save</button>
      <button v-else-if="docState === 'editing'" @click="docState = 'saved'">Cancel</button>
    </Transition>
  </div>
</template>

<script lang="ts" setup>
import { ref } from 'vue'

const isShow = ref(true)
const docState = ref('saved')
const state = ref(1)
</script>

<style lang="scss" scoped>
// button {
//   position: absolute;
// }

.slide-up-enter-active,
.slide-up-leave-active {
  transition: all 0.25s ease-out;
}

.slide-up-enter-from {
  opacity: 0;
  transform: translateY(30px);
}

.slide-up-leave-to {
  opacity: 0;
  transform: translateY(-30px);
}

.box1 {
  // position: absolute;
  width: 100px;
  height: 100px;
  background-color: green;
  // transition: all 5s ease;
}

.box2 {
  // position: absolute;
  width: 100px;
  height: 100px;
  background-color: aqua;
}

.box3 {
  width: 100px;
  height: 100px;
  background-color: red;
}

.fade-leave-to {
  transform: translate3d(0, -30px, 0);
}

.fade-enter-from {
  transform: translate3d(0, 30px, 0);
}

.fade-enter-active,
.fade-laeve-active {
  transition: transform 2s ease-out;
}
</style>
